// src/router/modules/routes.ts
import { RouteRecordRaw } from 'vue-router';

// 导入我们的新布局组件
import TabLayout from '@/layouts/TabLayout.vue';

const routes: Array<RouteRecordRaw> = [
  // **父路由，承载所有带 Tab 的页面**
  {
    path: '/',
    name: 'TabLayout', 
    component: TabLayout,
    // 子路由会渲染在 TabLayout 的 <router-view> 中
    redirect: '/home', 
    children: [
      {
        path: 'home', 
        name: 'Home',
        component: () => import('@/views/home/index.vue'),
        meta: { 
          title: '首页', 
          isTab: true, // 自定义元信息，标记为 Tab 页面
          index:1,
        } 
      },
      {
        path: 'message',
        name: 'Message',
        component: () => import('@/views/message/index.vue'),
        meta: { 
          title: '消息',
          isTab: true,
          index:1,
        }
      },
      {
        path: 'me',
        name: 'Me',
        component: () => import('@/views/me/index.vue'),
        meta: { 
          title: '我的',
          isTab: true,
          index:1,
        }
      }
    ]
  },
  
  // **顶级路由，全屏显示，不带 Tab**
  {
    path: '/login',
    name: 'Login',
    component: () => import('@/views/login/index.vue'),
    meta: { 
      title: '登录',
      index: 10,
    }
  },
  // 比如再加一个设置页
  {
    path: '/settings',
    name: 'Settings',
    component: () => import('@/views/setting/index.vue'), 
    meta: {
      title: '设置',
      index: 11,
    }
  },
  {
    path: '/search_pexels',
    name: 'SearchPexels',
    component: () => import('@/views/search_pexels/index.vue'), 
    meta: {
      title: '搜索结果',
      index: 12,
      mustLogin: true,
    }
  },
  {
    path: '/pexels_detail',
    name: 'PexelsDetail',
    component: () => import('@/views/pexels_detail/index.vue'), 
    meta: {
      title: '详细信息',
      index: 13,
      mustLogin: true,
    }
  },
  {
    path: '/login',
    name: 'Login',
    component: () => import('@/views/login/index.vue'), 
    meta: {
      title: '登录',
      index: 20,
    }
  },
  {
    path: '/register',
    name: 'Register',
    component: () => import('@/views/register/index.vue'), 
    meta: {
      title: '注册',
      index: 21,
    }
  }
];

export default routes;
